<div class="row">
    <div class="col-md-12">
        <h1>Danh Mục <small>Danh sách danh mục</small></h1>
        <ol class="breadcrumb">
            <li><a href="<?php echo mns_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li class="active"><i class="fa fa-table"></i> Các danh mục hiện có</li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-md-12 col-xs-12">
        <p class="pull-right">
            <a class="btn btn-success" href="<?php echo mns_page_url(CATEGORY_SLUG.'/them'); ?>">
                <i class='glyphicon glyphicon-plus-sign'></i>
                Thêm danh muc
            </a>
        </p>
    </div>
    <div class="clearfix"></div>

    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-bordered table-hover tablesorter item-list" data-href='<?php echo mns_page_url(CATEGORY_SLUG.'/cap-nhat-trang-thai'); ?>'>
                <thead>
                    <tr>
                        <th class="header"># <i class="fa fa-sort"></i></th>
                        <th class="header">Tên danh mục <i class="fa fa-sort"></i></th>
                        <th class="header">Danh mục cha <i class="fa fa-sort"></i></th>
                        <th class="header">Thứ tự <i class="fa fa-sort"></i></th>
                        <th class="header">Hiển thị</th>
                    </tr>
                    <tr class="tr-temp hidden warning">
                        <td colspan="6">
                            <form role="form" method="post" action="<?php echo mns_page_url(CATEGORY_SLUG.'/cap-nhat'); ?>" data-callback="1">
                                <div class="row">
                                    <div class="col-md-8 col-xs-12">
                                        <div class="form-group">
                                            <label for="input-category-title">Tên danh mục</label>
                                            <input type="text" class="form-control auto-slug" follow-ctr='.input-category-slug' id="input-category-title" name="category[title]" value="" />
                                        </div>
                                        <div class="form-group">
                                            <label for="input-category-slug">Đường dẫn</label>
                                            <input type="text" class="form-control input-category-slug" id="input-category-slug" name="category[slug]" value="" />
                                        </div>
                                        <div class="form-group">
                                            <label for="input-category-cate">Danh mục cha</label>
                                            <select class="form-control" id="input-category-cate" name="category[cate_flh]">
                                                <?php foreach($aParentCate as $pCate) { ?>
                                                <option value="<?php echo $pCate->getId(); ?>" data-href="<?php echo category_url($pCate->getSlug()); ?>">
                                                    <?php echo $pCate->getTitle(); ?>
                                                </option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-xs-12">
                                        <div class="form-group">
                                            <label for="input-category-order">Thứ tự</label>
                                            <input type="text" class="form-control" id="input-category-order" name="category[order]" value="" />
                                        </div>
                                        <div class="checkbox">                                            
                                            <label for="input-category-delete-flg"><input type="checkbox" id="input-category-delete-flg" name="category[delete_flg]" value="1"/> Hiển thị</label>
                                        </div>
                                        <div class="form-group">
                                            <input type="hidden" name="category[id]" id="input-category-id" />
                                            <button type="button" class="btn btn-success btn-submit-update"><i class='glyphicon glyphicon-ok-sign'></i> Cập nhật</button>
                                            <button type="button" class="btn btn-danger btn-cancel-update"><i class='glyphicon glyphicon-remove-sign'></i> Huỷ</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($aCategory as $index=>$category) { ?>
                    <tr class="can-edit" data-id="<?php echo $this->encrypt->encode($category->getId()); ?>">
                        <th class="header bg-info"><?php echo $index+1; ?></th>
                        <td class="input-category-title">
                            <h4 class="strong big-title">
                                <a class="category-title text-capitalize" href="<?php echo mns_category_single_url($category->getSlug()); ?>">
                                    <?php echo $category->getTitle(); ?>
                                </a>
                            </h4>
                            <p>
                                <a class="btn btn-success category-slug" target="_blank" data-slug='<?php echo $category->getSlug(); ?>' href="<?php echo shop_cate_url($category->shop_cate_slug, $category->getSlug()); ?>">
                                    <i class="glyphicon glyphicon-share-alt"></i> Xem
                                </a>
                            </p>
                            <p>[<em><?php echo fdate_format($category->getCreatedAt()); ?></em>]</p>
                        </td>
                        <td class="input-category-cate" data-cate-id="<?php echo $category->getCateId(); ?>">
                            <h4>
                                <?php
                                $pCateName = '';
                                foreach($aParentCate as $pCate){
                                    if($pCate->getId() == $category->getId()){
                                        $pCateName = $pCate->getTitle();
                                    }
                                }
                                ?>
                                <a class="label label-danger" target="_blank" href="<?php echo category_url($category->cate_slug); ?>"><?php echo $pCateName; ?></a>
                            </h4>
                        </td>
                        <td class="input-category-order strong"><?php echo $category->getOrder(); ?></td>
                        <td class="input-category-flg">
                            <div class="checkbox">
                                <input id="chk-del-<?php echo $index; ?>" class="input-category-delete-flg lb-toggle"
                                data-name="publish_flg" type="checkbox"  value="1"
                                <?php echo $category->getDeletedAt()==NULL ?"checked='checked'":''; ?> />
                                <label for="chk-del-<?php echo $index; ?>"></label>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="clearfix"></div>
</div>